home *** CD-ROM | disk | FTP | other *** search
/ Joystick Magazine 1996 May / cd joy 71No13.iso / pc / demos / eurosoc / source / euro_int.cpp < prev    next >
C/C++ Source or Header  |  1996-03-19  |  7KB  |  263 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4.  
  5. #include "eurodefs.h"
  6. #include "euro_sym.h"
  7. #include "euro_def.h"
  8. #include "euro_int.h"
  9. #include "euro_mem.h"
  10. #include "euro_dsk.h"
  11. #include "euro_spt.h"
  12.  
  13.         //…ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕª 
  14.         //∫                   ∫
  15.         //∫ EURO 96 LINK DATA ∫
  16.         //∫                   ∫
  17.         //»ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕº 
  18.  
  19. interface_data    EUROmatch_info;
  20.  
  21. extern    char    EUROsymbol;
  22. extern    BYTE    *TextStringMemHandle;
  23. extern    void    Euro96initialise();
  24. extern    char     EUROteamA, EUROteamB;
  25. extern    void    TransferDataToMatchInfo();
  26.  
  27.  
  28.  
  29. void    TempFrontend()
  30.     {
  31.         EUROsymbol = 1;
  32.         TextStringMemHandle    =    0;
  33.         TextStringMemHandle  =                    // Set up memory handle.
  34.             AllocateTextStringMemory();            // Allocate memory for text strings..
  35.  
  36.         printf    ("˛ %d Bytes allocated for script file text.\n", TEXT_STRING_BUFFER_LEN);
  37.         fflush(stdout);
  38.  
  39.         if ( EUROsymbol == 1 )
  40.         {
  41.             printf    ("˛ Symbol creation flag set.\n");
  42.  
  43.                     
  44.             fp2=fopen( "euro_sym.h", "wb" );
  45.                 if(fp2==NULL)
  46.                 {
  47.                     EUROsymbol = 0;
  48.                     printf    ("˛ Error trying to create symbol table.\n");
  49.                     fflush(stdout);
  50.                 }
  51.         }
  52.  
  53.         process_script_file("..\\script\\script.96");        // Reads script file and compiles relevent data for game.
  54.  
  55.         if ( EUROsymbol == 1 )
  56.         {
  57.             fclose(fp2);                        
  58.              printf    ("˛ Symbol table created.\n");
  59.             fflush(stdout);
  60.         }                
  61.  
  62.         Euro96initialise();
  63.  
  64.  
  65.     // additions for laurent.
  66.  
  67.         strcpy( &EUROmatch_info.TeamAname[0], GetTEAMname( 0, 11) );
  68.         strcpy( &EUROmatch_info.TeamBname[0], GetTEAMname( 1, 11) );
  69.         for ( char t=0; t < 16; t++ )                        // Reset all squads, making team
  70.         {for ( char p=0; p < 20; p++ ){SquadInfo[ (t*20)+p ] = p;}}        // lists run from plyr 1 to 20.
  71.  
  72.         TransferDataToMatchInfo();
  73.  
  74.     // ------------------------------------
  75.     }
  76.  
  77. void    ExitFrontend()
  78.     {
  79.         DeAllocateMemory(TextStringMemHandle);
  80.     }
  81.  
  82.  
  83.  
  84.  
  85. //********************************************************************************************************************************
  86.  
  87. void    TransferDataToMatchInfo()
  88.     {
  89.         short    PlyrIndex1, PlyrIndex2;        
  90.  
  91.             for (char p=0; p<20; p++)
  92.             {        
  93.                 PlyrIndex1 = NormalisePlayer( p, EUROteamA );
  94.                 PlyrIndex2 = NormalisePlayer( p, EUROteamB );
  95.                 
  96.                 EUROmatch_info.TeamA[p].pace           =    Pace[ PlyrIndex1 ];
  97.                 EUROmatch_info.TeamA[p].power           =    Power[ PlyrIndex1 ];
  98.                 EUROmatch_info.TeamA[p].control           =    Control[ PlyrIndex1 ];
  99.                 EUROmatch_info.TeamA[p].flair           =    Flair[ PlyrIndex1 ];
  100.                 EUROmatch_info.TeamA[p].vision           =    Vision[ PlyrIndex1 ];
  101.                 EUROmatch_info.TeamA[p].accuracy       =    Accuracy[ PlyrIndex1 ];
  102.                 EUROmatch_info.TeamA[p].stamina       =    Stamina[ PlyrIndex1 ];
  103.                 EUROmatch_info.TeamA[p].discipline     =    Discipline[ PlyrIndex1 ];
  104.                 EUROmatch_info.TeamA[p].fitness     =    Fitness[ PlyrIndex1 ];
  105.  
  106.                 EUROmatch_info.TeamB[p].pace        =    Pace[ PlyrIndex2 ];
  107.                 EUROmatch_info.TeamB[p].power        =    Power[ PlyrIndex2 ];
  108.                 EUROmatch_info.TeamB[p].control        =    Control[ PlyrIndex2 ];
  109.                 EUROmatch_info.TeamB[p].flair        =    Flair[ PlyrIndex2 ];
  110.                 EUROmatch_info.TeamB[p].vision        =    Vision[ PlyrIndex2 ];
  111.                 EUROmatch_info.TeamB[p].accuracy    =    Accuracy[ PlyrIndex2 ];
  112.                 EUROmatch_info.TeamB[p].stamina      =    Stamina[ PlyrIndex2 ];
  113.                 EUROmatch_info.TeamB[p].discipline     =    Discipline[ PlyrIndex2 ];
  114.                 EUROmatch_info.TeamB[p].fitness     =    Fitness[ PlyrIndex2 ];
  115.             }
  116.  
  117.         }
  118.  
  119. //********************************************************************************************************************************
  120.  
  121. short    NormalisePlayer( char plyr, char team )
  122.     {
  123.         short    PlyrIndex, P;
  124.         P      =    (team*20)+plyr;
  125.         PlyrIndex =    (team*20)+SquadInfo[ P ];
  126.         return(PlyrIndex);
  127.     }
  128.  
  129. //********************************************************************************************************************************
  130.  
  131. char    *GetTEXT( short StringNumber )
  132. {
  133.     return( (char *)Text[ StringNumber ] );
  134. }
  135.  
  136. //********************************************************************************************************************************
  137.  
  138. char    *GetPLAYERSname( char player, char team, char format )
  139.     {
  140.         short    Prefix        =    (team*20)+player;
  141.         char    *Search        =    GetTEXT( PLYR_NMES+Prefix );
  142.         char    NAMEoffset    =    0;
  143.         char    Searchlen    =    strlen(&Search[0]);
  144.         unsigned char     c;
  145.         
  146.         if ( format == FULL_NAME )
  147.         {    
  148.             for ( char x=0; x < Searchlen ; x++ )
  149.                 {StringBuffer[x]    = *(Search+x);}
  150.             StringBuffer[x]    = 0;
  151.         }
  152.  
  153.  
  154.         if ( format == INITIAL_SURNAME )
  155.         {    
  156.             // *** Get players initials ***
  157.         
  158.             for ( char x=0; x < Searchlen ; x++ )
  159.                 {
  160.                     if ( IsUpper[ *(Search+x) ] == up && 
  161.                          IsUpper[ *(Search+(x+1)) ] == lw && 
  162.                         NAMEoffset < (NAME_BUFFER_LEN-3) ) 
  163.                     {
  164.                         StringBuffer[NAMEoffset]     = *(Search+x);
  165.                         NAMEoffset++;
  166.         
  167.                         if ((*(Search+x))=='-')
  168.                             StringBuffer[NAMEoffset]     = '-';
  169.                         else                                    
  170.                             StringBuffer[NAMEoffset]     = '.';
  171.         
  172.                         StringBuffer[NAMEoffset+1]     = 32;
  173.                         NAMEoffset+=    2;
  174.                     }
  175.         
  176.                     if ((*(Search+x))=='-' && NAMEoffset >1 )
  177.                     {
  178.                               StringBuffer[NAMEoffset-2]     = '-';
  179.                               NAMEoffset--;
  180.                     }
  181.                 }    
  182.         }
  183.         
  184.         if ( format == INITIAL_SURNAME || format == SURNAME )
  185.         {    
  186.         
  187.             // *** Get players surname ***
  188.         
  189.             for ( char y=0; y < Searchlen ; y++ )
  190.                 {
  191.                     if ( IsUpper[ *(Search+y) ] == up && 
  192.                          IsUpper[ *(Search+(y+1)) ] == up && 
  193.                         NAMEoffset < (NAME_BUFFER_LEN-3) ) 
  194.  
  195.                     {
  196.                         StringBuffer[NAMEoffset]     = *(Search+y);
  197.         
  198. //                        if ( (IsUpper[ *(Search+(y-1) ) ] == up && y>0) && 
  199. //                             NamePREFIXtbl[Prefix] == 1 &&
  200. //                             ( (StringBuffer[NAMEoffset-1]!='c' || 
  201. //                            StringBuffer[NAMEoffset-2]!='M' && NAMEoffset>1 ) ) )
  202. //                            {                                
  203. //                                c = StringBuffer[NAMEoffset];
  204. //                                StringBuffer[NAMEoffset] = ToLower[c];
  205. //                            }
  206.  
  207.  
  208.  
  209.                         if ( (IsUpper[ *(Search+(y-1) ) ] == up && y>0) )
  210.                         {
  211.                             c = StringBuffer[NAMEoffset];
  212.  
  213.                             if ( ( StringBuffer[NAMEoffset-2]=='M' &&
  214.                                    StringBuffer[NAMEoffset-1]=='c' && 
  215.                                    NAMEoffset>1 && NamePREFIXtbl[Prefix] == 1 )
  216.                                )
  217.  
  218.                                 c = StringBuffer[NAMEoffset];
  219.  
  220.                             else
  221.  
  222.                                {                                
  223.                                 c = StringBuffer[NAMEoffset];
  224.                                 StringBuffer[NAMEoffset] = ToLower[c];
  225.                                }
  226.  
  227.                         }
  228.                         
  229.                         NAMEoffset++;
  230.                     }
  231.         
  232.                     else
  233.                     
  234.                         if ( IsUpper[ *(Search+y) ] == up && 
  235.                              IsUpper[ *(Search+(y-1)) ] == up && 
  236.                             NAMEoffset < (NAME_BUFFER_LEN-3) && y>0 ) 
  237.                         {
  238.                             StringBuffer[NAMEoffset]     = *(Search+y);
  239.         
  240.                             if ( IsUpper[ *(Search+(y-1)) ] == up && y>0 )
  241.                             {                                
  242.                                 c = StringBuffer[NAMEoffset];
  243.                                 StringBuffer[NAMEoffset] = ToLower[c];
  244.                             }
  245.         
  246.                             NAMEoffset++;
  247.                     
  248.                                 if ( (*(Search+(y+1)))==' ')
  249.                                 {
  250.                                     StringBuffer[NAMEoffset]     = 32;
  251.                                     NAMEoffset++;
  252.                                 }
  253.                         }
  254.                 }    
  255.  
  256.             StringBuffer[NAMEoffset]    =    0;    // end of line.
  257.         }
  258.  
  259.         return    ( &StringBuffer[0] );
  260.     }
  261.  
  262. //********************************************************************************************************************************
  263.